﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CPPEI.Coolzon.Designer.Views
{
    /// <summary>
    /// Interaction logic for SceneProperty.xaml
    /// </summary>
    public partial class SceneProperty : Window
    {
        private Designtime.Metadata.Scene _scene;
        public SceneProperty(Designtime.Metadata.Scene scene)
        {
            InitializeComponent();
            _scene = scene;
        }

        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            tbID.Text = _scene.ID.ToString();
            tbName.Text = _scene.Name;
            tbTitle.Text = _scene.Caption;
            if (_scene.RT_Scene.IsAllowSwapArea)
            {
                cbAllowSwap.SelectedIndex = 0;
            }
            else
            {
                cbAllowSwap.SelectedIndex = 1;
            }
            if (_scene.RT_Scene.IsShowInNavigation)
            {
                cbShowNavigate.SelectedIndex = 0;
            }
            else
            {
                cbShowNavigate.SelectedIndex = 1;
            }
        }

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            System.Windows.Input.KeyboardDevice kd = e.KeyboardDevice;
            if (e.Key == Key.D && (kd.GetKeyStates(Key.RightCtrl) & System.Windows.Input.KeyStates.Down) > 0 && (kd.GetKeyStates(Key.LeftAlt) & System.Windows.Input.KeyStates.Down) > 0)
            {
                if(faID.Visibility == Visibility.Collapsed)
                {
                    faID.Visibility = Visibility.Visible;
                    _RDID.Height = new GridLength(45);
                }
                else
                {
                    faID.Visibility = Visibility.Collapsed;
                    _RDID.Height = new GridLength(0);
                }
            }
        }
    }
}
